package net.lainiao.service.service;

import net.lainiao.base.model.ShiroUser;
import net.lainiao.base.model.ShiroUserRole;
import net.lainiao.base.model.exp.ShiroUserRoleExp;
import net.lainiao.service.dao.ShiroUserRoleMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by Administrator on 2017/1/19.
 */
@Service
public class ShiroUserRoleService {
    @Resource
    private ShiroUserRoleMapper shiroUserRoleMapper;

    public int save(ShiroUserRole shiroUserRole) {
        if(shiroUserRole.getId()==null){
            return shiroUserRoleMapper.insert(shiroUserRole);
        }
        return shiroUserRoleMapper.updateByPrimaryKey(shiroUserRole);
    }

    public int del(int id) {
        return shiroUserRoleMapper.deleteByPrimaryKey(id);
    }

    public ShiroUserRole getModelById(int id) {
        return  shiroUserRoleMapper.selectByPrimaryKey(id);
    }

    public List<ShiroUserRoleExp> getUserRoleExpByUserId(int userId) {
        return shiroUserRoleMapper.getUserRoleExpByUserId(userId);
    }

    public int getCountByUserIdRoleId(Integer userId, Integer roleId) {
        return shiroUserRoleMapper.getCountByUserIdRoleId(userId,roleId);
    }
}
